<?php
class ZipcodeCacheModel extends CI_Model {
	function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function getCacheData($zipcode, $type){
    	$this->db->where('type', $type);
		$query = $this->db->get_where('cache_data', array('ZipCode' =>$zipcode));
		$zipcodeCacheData = $query->result();
		if(count($zipcodeCacheData) > 0){
			return $zipcodeCacheData[0];
		}else{
			return null;
		}
    }
    function insertCacheData($data){
    	$this->db->insert('cache_data', $data); 
    }
	function updateCacheData($zipcode, $type, $data){
		$this->db->where('zipcode', $zipcode);
		$this->db->where('type', $type);
		$this->db->update('cache_data', $data);  
    }
}